<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>

<head>
    <style>
       .aa {
            color: red;
        }
    </style>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>


    <![endif]-->
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
        //日期的正则表达式^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$

        $(function() {
            $("#add").submit(function () {
                //设备编码
                var enumber = $("#enumber").val();
                var reg = /(QC)[0-9,a-z,A-Z]/
                if (reg.test(enumber) == false) {
                    $("#enumbers").html("设备编码:必须以QC开头");
                    return false;
                }
                $("#enumbers").html();

//用户id
                var userid = $(".c").val();
                if (userid == -1) {
                    $("#userids").html("净水器id:未选择");
                    return false;
                }
                $("#userids").html();
//净水器id
                var wpid = $(".a").val();
                if (wpid == -1) {
                    $("#wpids").html("净水器id:未选择");
                    return false;
                }
                $("#wpids").html();
//是否预约装机
                var install = $(".b").val();
                if (install == -1) {
                    $("#installs").html("是否装机:未选择");
                    return false;
                }
                $("#installs").html();

                    var ss=true;
                    if(ss==true){
                        layer.alert("增加成功", {icon: 6})
                    }else if(ss==false){
                        layer.alert("增加失败", {icon: 6})
                    }

            });
            $("select").val(-1);
        });
    </script>
</head>

<body>
<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form" id="add" action="Servletadd" method="post">

        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>设备编码
            </label>
            <div class="layui-input-inline">
                <input type="text" id="enumber" name="enumber" required="" lay-verify="enumber"
                       autocomplete="off" class="layui-input">
                <span id="enumbers" class="aa"></span>
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>生产日期
            </label>
            <div class="layui-input-inline">
                <input type="date" id="manufactureTime" name="manufactureTime" required="" lay-verify="manufactureTime"
                       autocomplete="off" class="layui-input">
                <span id="manufactureTimes" class="aa"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>用户
            </label>
            <div class="layui-input-inline">

                <select name="userid" class="c">
                    <option value="-1">--请选择--</option>
                    <c:forEach  items="${listl}" var="t">

                        <option value="${t.uid}">${t.uname}</option>

                    </c:forEach>
                </select>
                <span id="userids" class="aa"></span>
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>净水器
            </label>
            <div class="layui-input-inline">

                <select name="wpid" class="a">
                    <option value="-1">--请选择--</option>
                    <c:forEach  items="${listk}" var="p">

                        <option value="${p.wpid}">${p.waterName}</option>

                    </c:forEach>
                </select>
                <span id="wpids" class="aa"></span>
            </div>
        </div>


        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>是否装机
            </label>
            <div class="layui-input-inline">
                <select name="install"  class="b">
                    <option value="-1">--请选择--</option>
                    <option value="0">未装机</option>
                    <option value="1">已装机</option>
                </select>
                <span id="installs" class="aa"></span>
            </div>
        </div>

        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>分配时间
            </label>
            <div class="layui-input-inline">
                <input type="date" id="allocationDate" name="allocationDate" required="" lay-verify="allocationDate"
                       autocomplete="off" class="layui-input">
                <span id="allocationDates" class="aa"></span>
            </div>
        </div>



        <%--<div class="layui-form-item">--%>
            <%--<label for="L_repass" class="layui-form-label">--%>
            <%--</label>--%>
            <%--<button  class="layui-btn" lay-filter="add" lay-submit="">--%>
                <%--增加--%>
            <%--</button>--%>
        <%--</div>--%>

        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <input  class="layui-btn" lay-filter="add" lay-submit="" type="submit" value="增加"/>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
//        form.verify({
//            pname: function(value){
//                if(value.length < 4){
//                  return '昵称至少得4个字符 啊';
//                }
//            }
//            ,pno: [/(RH)\d/, '设备编码必须RH开头']
//            ,userid: [/\d/, '设备编码必须数字类型']
//        });




    });
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>